/*
 * Minimal configuration file
 */

/*
 *		Device list:
 *			0x00: bus id (16 bit, input)
 *			0x01: primary rs232 data port (8 bit, input/output)
 *			0x02: primary rs232 control register (2 bit, input)
 *			0x03: instruction counter (32 bit, input)
 *			0x04: millisecond clock (32 bit, input)
 *			0x05: display (16 bit, output)
 *			0x06: switches (8 bit, input)
 *			0x07: leds (8 bit, output)
 *			0x08: buttons (4 bit, input)
 * 			0x09: processor state register (8 bit input)
 */

#include "peripherals/1to1.vh"
#include "peripherals/rs232.vh"
#include "peripherals/4x7seg.vh"
#include "peripherals/clock.vh"
#include "peripherals/timer.vh"
#include "peripherals/softint.vh"
#include "s3starter_pins.h"

#define TARGET xs3e400
#define CLOCKSPEED 50000000
#define CORE_SIZE_LONG 32
#define CORE_SIZE_INT 32
#define CORE_SIZE_SHORT 16
#define CORE_SIZE_POINTER 32
#define ROM_LOCATION 0x000C0000
#define ROM_ADDRESS_BITS 16

#define INITIAL_RESET buttons(3) = '1'
#define NORMAL_RESET buttons = "1111"

#define PERIPHERAL_ADDRESS_BITS				8
#define PERIPHERAL_DATA_BITS 					32
#define PERIPHERAL_ID									2

#define INSTRUCTION_COUNTER_INDEX 0x03
#define PROCSTATE_REGISTER_INDEX 0x09

#define LIBCODE_X32_MS_CLOCK (peripherals[0x04])
#define LIBCODE_X32_US_CLOCK (peripherals[0x32])
#define LIBCODE_X32_STDOUT (peripherals[0x01])
#define LIBCODE_X32_STDOUT_STATUS (peripherals[0x02] & 0x01)
#define LIBCODE_X32_STDIN (peripherals[0x01])
#define LIBCODE_X32_STDIN_STATUS (peripherals[0x02] & 0x02)

ADD_1TO1_INPUT_DEVICE(switches, 0x06, 0x08, 8, PIN_SWITCHES)
ADD_1TO1_INPUT_DEVICE(buttons, 0x08, 0x07, 4, PIN_BUTTONS)
ADD_1TO1_OUTPUT_DEVICE(leds, 0x07, 8, PIN_LEDS)
ADD_RS232_DEVICE(primary, 0x01, 0x02, 8, 8, 115200, PIN_PRIMARY_TX, PIN_PRIMARY_RX, 0x09, 0x0A)
ADD_4x7SEGDISP_DEVICE(display, 0x05, PIN_DISPLAY_DATA, PIN_DISPLAY_CONTROL)
ADD_CLOCK_DEVICE(ms_clock, 0x04, 50000)
